home *** CD-ROM | disk | FTP | other *** search
/ Whiteline: Alpha / Whiteline Alpha.iso / tools / cpx_acc / cpxbasic / sources / p2clib.c < prev    next >
Encoding:
C/C++ Source or Header  |  1994-09-22  |  1.6 KB  |  71 lines

  1. /* Run-time library for use with "p2c", the Pascal to C translator */
  2.  
  3. /* "p2c"  Copyright (C) 1989, 1990, 1991 Free Software Foundation.
  4.  * By Dave Gillespie, daveg@csvax.cs.caltech.edu.  Version --VERSION--.
  5.  * This file may be copied, modified, etc. in any way.  It is not restricted
  6.  * by the licence agreement accompanying p2c itself.
  7.  */
  8.  
  9. /*
  10. ** file changed by J.S. 1993
  11. ** removed unneeded functions 
  12. */
  13. #ifndef NO_TIME
  14. # include <time.h>
  15. #endif
  16. #include "p2c.h"
  17.  
  18.  
  19. #define Isspace(c)  isspace(c)      /* or "((c) == ' ')" if preferred */
  20.  
  21. int P_argc;
  22. char **P_argv;
  23.  
  24. short P_escapecode;
  25. int P_ioresult;
  26.  
  27. long EXCP_LINE;    /* Used by Pascal workstation system */
  28.  
  29. __p2c_jmp_buf *__top_jb;
  30.  
  31.  
  32. void PASCAL_MAIN(int argc, char **argv)
  33. {
  34.     P_argc = argc;
  35.     P_argv = argv;
  36.     __top_jb = NULL;
  37.  
  38. #ifdef LOCAL_INIT
  39.     LOCAL_INIT();
  40. #endif
  41. }
  42.  
  43. /* HP and Turbo Pascal string functions: */
  44. /* Trim blanks at left end of string. */
  45. char *strltrim(register char *s)
  46. {
  47.     while (Isspace(*s++)) ;
  48.     return s - 1;
  49. }
  50.  
  51. void _Escape(int code)
  52. {
  53.     P_escapecode = code;
  54.     if (__top_jb) {
  55.     __p2c_jmp_buf *jb = __top_jb;
  56.     __top_jb = jb->next;
  57.     longjmp(jb->jbuf, 1);
  58.     }
  59.     if (code == 0) exit(EXIT_SUCCESS);
  60.     exit(EXIT_FAILURE);
  61. }
  62.  
  63. void _EscIO(int code)
  64. {
  65.     P_ioresult = code;
  66.     _Escape(-10);
  67. }
  68.  
  69. void *BASalloc(long num)
  70. {
  71.     void *temp=malloc(num);
  72.     char *ptr;
  73.     if(temp==NULL) _Escape(-2);
  74.     ptr=(char*)temp;
  75.     while(num-->0) *ptr++=0;
  76.     return temp;
  77. }
  78.  
  79. void *BASrealloc(void *buf,long num)
  80. {
  81.     void *temp;
  82.     if((temp=realloc(buf,num))==NULL) _Escape(-2);
  83.     return temp;
  84. }
  85.  
  86. /* End. */
  87.